COVID-19 Outbreak Data
This short report has been created using Jupyter Book and tries to visualize and analyze some data related to the COVID-19 outbreak.
The data are constantly updated from the repository by Johns Hopkins CCSE.
This is a work-in-progress, graphs will be addedd in the next days and week.
We use plotly bar chart for displaying the interactive charts.
import os,sys
sys.path.insert(0, os.path.normpath(os.path.join(os.path.abspath(''), '../../Code')))
from hedera_covid import DataHandler, plot_death_rate, plot_daily_cases, plot_confirmed_cases
# for plotly
from plotly.offline import iplot
from plotly.offline import init_notebook_mode, plot
from IPython.core.display import display, HTML
import plotly as py
import plotly.tools as tls
import numpy as np
# load data
path_confirmed = '../../Data/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv'
path_death = '../../Data/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv'
europe_covid_data = DataHandler(data_confirmed_path = path_confirmed,data_death_path = path_death)
america_covid_data = DataHandler(data_confirmed_path = path_confirmed,data_death_path = path_death)
Europe = ['Italy','Spain','Germany','France','United Kingdom',
'Netherlands','Belgium','Portugal','Sweden','Austria']
for c in Europe:
europe_covid_data.add_country(c)
Total number of cases
The number of (reported) cases is strongly dependent on the capacity and on the politics of each country in terms of tests. Realistic estimates can only be obtained starting from (realistic estimates of) the number of deaths and of the death rate.
Nevertheless, the number of reported cases can provide a measure of the spread of the virus.
The following figure shows the number of reported cases, shifting the curves so that they start when the number of infected persons reached 100. The number has also been smoothed taking, for each day, the average of a week (3 days before and 3 days after).
You can double click on a country name on legend to isolate its data. Simple clicking on a name will switch on/off the corresponding data.
# confirmed
data = europe_covid_data.get_confirmed_data(start_date=0,n_smooth=0,rescale=True)
covid_data = europe_covid_data
init_notebook_mode(connected=True)
fig = {
"data": data,
"layout": {"title": {"text": "Confirmed Cases (rescaled in each country)"}}
}
plot(fig, filename = 'figure.html')
display(HTML('figure.html'))
data = europe_covid_data.get_daily_confirmed_data(start_date=0,n_smooth=7,rescale=True)
init_notebook_mode(connected=True)
fig = {
"data": data,
"layout": {"title": {"text": "Daily Cases (rescaled)"}}
}
plot(fig, filename = 'figure.html')
display(HTML('figure.html'))
These curves show whether and how the different countries are able to flatten the curves. Try to double-click on the legend, then switch on, country by country, Italy, Germany, and Spain.
data = europe_covid_data.get_deaths_data(start_date=40,n_smooth=7,rescale=False)
init_notebook_mode(connected=True)
fig = {
"data": data,
"layout": {"title": {"text": "Daily deaths (rescaled)"}, "legend_orientation": "h",
"legend" :{"x":0.3, "y": 1.15}
}
}
plot(fig, filename = 'figure.html')
display(HTML('figure.html'))
data = europe_covid_data.get_daily_deaths_data(start_date=0,n_smooth=7,rescale=True)
init_notebook_mode(connected=True)
fig = {
"data": data,
"layout": {"title": {"text": "Daily deaths (rescaled)"}, "legend_orientation": "h"}
}
plot(fig, filename = 'figure.html')
display(HTML('figure.html'))
data = europe_covid_data.get_death_rate_data(start_date=40,n_smooth=0,rescale=False)
init_notebook_mode(connected=True)
fig = {
"data": data,
"layout": {"title": {"text": "Daily deaths (rescaled)"},
"font_size":10,
"legend": {'x':1.05}
}
}
plot(fig,filename = 'figure.html')
display(HTML('figure.html'))
America = ['US','Canada','Mexico','Colombia','Peru',
'Chile','Brazil','Ecuador','Argentina']
for c in America:
america_covid_data.add_country(c)
# confirmed
data = america_covid_data.get_confirmed_data(start_date=0,n_smooth=0,rescale=True)
init_notebook_mode(connected=True)
fig = {
"data": data,
"layout": {"title": {"text": "Daily deaths (rescaled)"}, "legend_orientation": "h"}
}
plot(fig, filename = 'figure.html')
display(HTML('figure.html'))
data = america_covid_data.get_daily_confirmed_data(start_date=0,n_smooth=7,rescale=True)
init_notebook_mode(connected=True)
fig = {
"data": data,
"layout": {"title": {"text": "Daily Cases (rescaled)"}}
}
plot(fig, filename = 'figure.html')
display(HTML('figure.html'))
data = america_covid_data.get_daily_deaths_data(start_date=0,n_smooth=7,rescale=True)
init_notebook_mode(connected=True)
fig = {
"data": data,
"layout": {"title": {"text": "Daily deaths (rescaled)"}, "legend_orientation": "h"}
}
plot(fig, filename = 'figure.html')
display(HTML('figure.html'))